package com.ych.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ych.beans.Log;
import com.ych.beans.Message;
import com.ych.dao.LogDao;
import com.ych.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogServiceImpl implements LogService {
    @Autowired
    LogDao dao;
    @Override
    public Message selectLog(Integer pageNo, String key) {
        Message message = new Message();
        if(pageNo!=null){
            PageHelper.startPage(pageNo, 8);
        }
        List<Log> list=dao.selectLog(key);
        final PageInfo<Log> objectPageInfo = new PageInfo<>(list);
        if(!list.isEmpty()){
            message.setSuccess(true);
            message.setObj(objectPageInfo);
        }
        return message;
    }
}
